﻿@** Copyright 2013 Seven Spikes Ltd. All rights reserved. (http://www.nop-templates.com)
* http://www.nop-templates.com/t/licensinginfo
*@

@using Nop.Core;
@using Nop.Core.Infrastructure;
@using SevenSpikes.Nop.Plugins.AnywhereSliders.Models.Nivo
@using System.Globalization
@model NivoModel
@{
    Layout = null;

    string skin = Model.Settings.Theme ?? "";
}

@helper RenderSliderLine(string pictureUrl, string text, string alt, bool haveLink, string link)
{
    if (!string.IsNullOrEmpty(pictureUrl))
    {
        if (haveLink && !string.IsNullOrEmpty(link))
        {
            <a href="@link">
                @if (Model.Settings.ShowCaption)
                {
                    <img src="@pictureUrl" data-thumb="@pictureUrl" alt="@alt" title="@text" />
                }
                else
                {
                    <img src="@pictureUrl" data-thumb="@pictureUrl" alt="@alt" />
                }
            </a>
        }
        else
        {
            if (Model.Settings.ShowCaption)
            {
                <img src="@pictureUrl" data-thumb="@pictureUrl" alt="@alt" title="@text" />
            }
            else
            {
                <img src="@pictureUrl" data-thumb="@pictureUrl" alt="@alt" />
            }
        }
    }
}

@if (Model.SliderImages != null && Model.SliderImages.Count > 0)
{
    // add css
    Html.AddCssFileParts("~/Plugins/SevenSpikes.Nop.Plugins.AnywhereSliders/Styles/nivo/nivo-slider.css");
    Html.AddCssFileParts("~/Plugins/SevenSpikes.Nop.Plugins.AnywhereSliders/Themes/" + Model.Theme + "/Content/nivo/nivo.css");

    var supportRtl = EngineContext.Current.Resolve<IWorkContext>().WorkingLanguage.Rtl;
    if (supportRtl)
    {
        Html.AddCssFileParts("~/Plugins/SevenSpikes.Nop.Plugins.AnywhereSliders/Styles/nivo/nivo.rtl.css");
    }
    
    
    
    // add javascript
    Html.AppendScriptParts("~/Plugins/SevenSpikes.Nop.Plugins.AnywhereSliders/Scripts/nivo/jquery.nivo.slider.js");
    

    
    <div class="slider-wrapper theme-@skin">
        <div id="@Model.SliderHtmlElementId" class="nivoSlider">
            @foreach (var sliderImage in Model.SliderImages)
            {
                @RenderSliderLine(sliderImage.PicturePath, sliderImage.DisplayText, sliderImage.Alt, Model.Settings.Links, sliderImage.Url)
            }
        </div>
    </div>
    <script type="text/javascript">
        $(window).load(function () {
            $('#@Model.SliderHtmlElementId').nivoSlider({
                effect: '@Model.Settings.Effect', // Specify sets like: 'fold,fade,sliceDown'
                slices: @Model.Settings.Slices, // For slice animations
                boxCols:  @Model.Settings.BoxCols , // For box animations
                boxRows: @Model.Settings.BoxRows, // For box animations
                animSpeed: @Model.Settings.AnimationSpeed, // Slide transition speed
                pauseTime: @Model.Settings.AutoSlideInterval, // How long each slide will show
                startSlide: 0, // Set starting Slide (0 index)
                directionNav: @Model.Settings.EnableDirectionNavigation.ToString().ToLower(), // Next & Prev navigation
                controlNav: @Model.Settings.EnableControlNavigation.ToString().ToLower(), // 1,2,3... navigation
                controlNavThumbs: @Model.Settings.EnableControlNavigationThumbs.ToString().ToLower(), // Use thumbnails for Control Nav
                pauseOnHover: @Model.Settings.PauseOnHover.ToString().ToLower(), // Stop animation while hovering
                manualAdvance: false, // Force manual transitions
                prevText: '@Model.Settings.PrevText', // Prev directionNav text
                nextText: '@Model.Settings.NextText', // Next directionNav text
                randomStart: @Model.Settings.RandomStart.ToString().ToLower() // Start on a random slide
            });
        });            
    </script>
}